<template>
  <div class="home">
    <h1>页面列表</h1>
    <div class="page-list">
      <div v-for="route in availableRoutes" :key="route.name" class="page-item">
        <span>{{ route.meta.title }}</span>
        <button @click="goToPage(route.path)" class="go-button">前往</button>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name:"HomePage",
  data() {
    return {
    }
  },
  computed:{
    availableRoutes(){
      //过滤掉首页本身
      return this.$router.options.routes.filter(route=>route.path!=='/')
    }
  },
  components: {
  },
  methods: {
    goToPage(path){
      this.$router.push(path)
    }
  },
  mounted(){
    /** 初始执行 */
    /** 定时任务 */
  }
}
</script>

<style scoped>
.home {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px;
}
.page-list {
  margin-top: 30px;
}
.page-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 15px;
  margin-bottom: 10px;
  border: 1px solid #eee;
  border-radius: 4px;
}
.go-button {
  padding: 5px 10px;
  background-color: #42b983;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}
.go-button:hover {
  background-color: #3aa876;
}
</style>